package May;

import com.sun.jmx.snmp.SnmpNull;

import java.util.Arrays;
import java.util.Scanner;

public class DAY0523 {
    //计算日期到天数转换
    public static void main1(String[] args) {
        Scanner sc =new Scanner(System.in);
        //进行数据接收
        while (sc.hasNext()){
            int year = sc.nextInt();
            int month = sc.nextInt();
            int day = sc.nextInt();

            int day1 = ConversionDate(year,month,day);
            System.out.println(day1);
        }
    }
    public static int ConversionDate(int year,int month,int day){
        //判断年  闰年对应的二月份时间不一样
        //              1  2  3  4  5  6  7  8  9  10 11 12
        int[] months = {31,28,31,30,31,30,31,31,30,31,30,31};
        if (year%4 == 0 && year%100 != 0 ||year%400 ==0){
            months[1] = 29;//如果是闰年 2月有29
        }
        int sum = 0;
        for (int i = 0; i < month-1; i++) {
            sum = sum+months[i];
        }
        sum = sum+day;
        return sum;
    }






    //幸运袋子
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()){
            int n = sc.nextInt();
            int[] nums = new int[n];
            for (int i = 0; i < n; i++) {
                nums[i] = sc.nextInt();
            }
            //对当前球号码进行排序
            Arrays.sort(nums);
            int count = Luck(nums,0,0,1);
            System.out.println(count);
        }
    }

    private static int Luck(int[] nums, int i, int i1, int i2) {
        int count = 0;//用来计数
        for (int j = i; j < nums.length; j++) {
            i1 = i1+nums[j];//和
            i2 = i2*nums[j];//积

            if (i1>i2){
                count += 1+Luck(nums,j+1,i1,i2);//可以构成幸运袋子
            } else if (nums[j]==1) {
                count +=Luck(nums,j+1,i1,i2);
            }else {//不能构成幸运袋子
                break;
            }
            i1 = i1-nums[i];
            i2 = i2/nums[i];
            //跳过重复号码
            while (j<nums.length-1 && nums[j]==nums[j+1]){
                j++;
            }
        }
        return count;
    }
}
